package com.hlxy.fixdb;

import java.util.Arrays;
import java.util.Objects;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;


//@Configuration
@SpringBootApplication
@MapperScan("com.hlxy.fixdb.mapper")
@PropertySource("classpath:config.properties")
@ComponentScan(basePackages = {"com.hlxy.fixdb.*"})
public class FixDBApplication {
	 private static final Logger log = LoggerFactory.getLogger(FixDBApplication.class.getName());

	    public static void main(String[] args) {
	        new SpringApplicationBuilder().bannerMode(Banner.Mode.OFF)
	                .sources(FixDBApplication.class)
	                .run(args);
	    }

	    @Bean
	    public CommandLineRunner commandLineRunner(ApplicationContext ctx, Environment env) {
	        return args -> {
	            log.info("系统运行的配置:profile :{}", Arrays.toString(env.getActiveProfiles()));
	            String path = Objects.isNull(env.getProperty("server.contextPath")) ? "" : env.getProperty("server.contextPath");
	            log.info("项目主页:{}", "http://127.0.0.1:" + env.getProperty("server.port") + path);
	        };
	    }
}
